package com.nageoffer.jobtrain.projects.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.nageoffer.jobtrain.common.web.result.Result;
import com.nageoffer.jobtrain.common.web.result.Results;
import com.nageoffer.jobtrain.projects.dto.req.UserBlockingReqDTO;
import com.nageoffer.jobtrain.projects.dto.req.UserEditUserInfoReqDTO;
import com.nageoffer.jobtrain.projects.dto.req.UserLiftingReqDTO;
import com.nageoffer.jobtrain.projects.dto.req.UserPageReqDTO;
import com.nageoffer.jobtrain.projects.dto.resp.UserDetailRespDTO;
import com.nageoffer.jobtrain.projects.dto.resp.UserInfoRespDTO;
import com.nageoffer.jobtrain.projects.dto.resp.UserPageRespDTO;
import com.nageoffer.jobtrain.projects.service.UserService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * 用户接口控制层
 * author：唐晨
 */
@RestController
@RequiredArgsConstructor
public class UserController {
    private final UserService userService;

    /**
     * 用户分页查询
     */
    @PostMapping("/api/job-train/project/user/page")
    public Result<IPage<UserPageRespDTO>> pageUserList(UserPageReqDTO requestParam) {
        return Results.success(userService.pageUserList(requestParam));
    }

    /**
     * 用户状态拉黑功能
     */
    @PostMapping("/api/job-train/project/user/blocking")
    public Result<Void> blockingUserStatus(@RequestBody UserBlockingReqDTO requestParam) {
        userService.blockingUserStatus(requestParam);
        return Results.success();
    }

    /**
     * 用户状态解禁功能
     */
    @PostMapping("/api/job-train/project/user/lifting")
    public Result<Void> liftingUserStatus(@RequestBody UserLiftingReqDTO requestParam) {
        userService.liftingUserStatus(requestParam);
        return Results.success();
    }

    /**
     * 用户退出登录功能
     */
    @DeleteMapping("/api/job-train/project/user/logout")
    public Result<Boolean> logoutUser() {
        return Results.success(userService.logoutUser());
    }

    /**
     * 获取用户详情
     */
    @PostMapping("/api/job-train/project/user/detail")
    public Result<UserDetailRespDTO> detailUser() {
        return Results.success(userService.detailUser());
    }

    /**
     * 获取用户个人信息详情
     */
    @GetMapping("/api/job-train/project/user/get-info")
    public Result<UserInfoRespDTO> getUserInfo() {
        return Results.success(userService.getUserInfo());
    }

    /**
     * 编辑用户个人信息详情
     */
    @PostMapping("/api/job-train/project/user/edit-info")
    public Result<Void> editUserInfo(@RequestBody UserEditUserInfoReqDTO requestParam) {
        userService.editUserInfo(requestParam);
        return Results.success();
    }

    /**
     * 实现用户头像上传
     */
    @PostMapping("/api/job-train/project/user/upload")
    public Result<Void> upLoadUserHeadShot(@RequestParam("multipartFile") MultipartFile multipartFile) {
        userService.upLoadUserHeadShot(multipartFile);
        return Results.success();
    }
}
